<template>
    <el-dialog
            title="设置目标值"
            :visible.sync="dialogParams.visible"
            width="30%">
        <div class="targetValue">
            <p>目标值：</p>
            <el-input v-model.number="targetValue" placeholder="请输入目标值"></el-input>
        </div>
        <span slot="footer" class="dialog-footer">
            <el-button @click="close">取 消</el-button>
            <el-button type="primary" @click="submit">确 定</el-button>
          </span>
    </el-dialog>
</template>

<script>
    export default {
        name: 'setTargetValue',
        props: {
            dialogParams: {
                type: Object
            }
        },
        data() {
            return {
                targetValue: ''
            }
        },
        created() {
            this.targetValue = this.dialogParams.data.targetValue
        },
        methods: {
            submit() {
                if (this.targetValue) {
                    this.dialogParams.data.targetValue = this.targetValue
                    this.$emit('setTargetValue', this.dialogParams.data);
                    this.dialogParams.visible = false
                } else {
                    this.$message.error('请输入目标值')
                }
            },
            close() {
                this.targetValue = '';
                this.dialogParams.visible = false
            }
        }
    }
</script>

<style lang="scss" scoped>
.targetValue{
    display: flex;
    align-items: center;
    p{
        width: 80px;
    }
}
</style>